package com.chen.admin.controller;


import com.chen.admin.common.Result;
import com.chen.admin.entity.HotelBooking;
import com.chen.admin.service.HotelBookingService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin(origins = "http://localhost:8080")
@RequestMapping("/hotelBooking")
public class HotelBookingController {


    @Autowired
    private HotelBookingService hotelBookingService;

    /**
     * 获取订单列表展示
     */

    @GetMapping("/getHotelBookingsPage")
    public Result<PageInfo<HotelBooking>> getHotelBookingsPage(@RequestParam(defaultValue = "1") Integer pageNumber, @RequestParam(defaultValue = "10") Integer pageSize) {
        PageHelper.startPage(pageNumber, pageSize);
        List<HotelBooking> hotelBookingList = hotelBookingService.getHotelBookings();
        return Result.success(new PageInfo<>(hotelBookingList));
    }

    /**
     * 删除订单操作
     */
    @DeleteMapping("/deleteHotelBookings/{id}")
    public Result deleteHotelBookings(@PathVariable Integer id) {
        Result result = hotelBookingService.deleteHotelBookings(id);
        return result;
    }

    /**
     * 批量删除
     */

    @DeleteMapping("/deleteHotelBookingsByIds")
    public Result deleteHotelBookingsByIds(@RequestBody List<Integer> ids) {

        Result result = hotelBookingService.deleteHotelBookingsByIds(ids);
        return result;

    }

    /**
     * 编辑功能
     */

    @PutMapping("/updateHotelBookings")
    public Result updateHotelBookings(@RequestBody HotelBooking hotelBooking) {
        Result result = hotelBookingService.updateHotelBookings(hotelBooking);
        return result;
    }




}
